﻿using Education.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Education.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {
        public DataTemplate BulletinTemplate { get; set; }
        public DataTemplate NormalTemplate { get; set; }
        public DataTemplate TourTemplate { get; set; }

        public DataTemplate OverviewTemplate { get; set; }
        public DataTemplate AdmissionTemplate { get; set; }
        public DataTemplate CurriculamTemplate { get; set; }

        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            if (item != null && element != null)
            {
                if (item.GetType() == typeof(HubPageDataItem))
                {
                if ((item as HubPageDataItem).UniqueId.StartsWith("Bulletin"))
                    return BulletinTemplate;
                if ((item as HubPageDataItem).UniqueId.StartsWith("Normal"))
                    return NormalTemplate;
                if ((item as HubPageDataItem).UniqueId.StartsWith("Tour"))
                    return TourTemplate;
                }

                else if (item.GetType() == typeof(Spoke1DataItem))
                {
                    if ((item as Spoke1DataItem).UniqueId.StartsWith("Overview"))
                        return OverviewTemplate;
                    if ((item as Spoke1DataItem).UniqueId.StartsWith("Admission"))
                        return AdmissionTemplate;
                    if ((item as Spoke1DataItem).UniqueId.StartsWith("Curriculam"))
                        return CurriculamTemplate;
                    if ((item as Spoke1DataItem).UniqueId.StartsWith("Normal"))
                        return NormalTemplate;
                }

                else if (item.GetType() == typeof(Spoke2DataItem))
                {
                    if ((item as Spoke2DataItem).UniqueId.StartsWith("Bulletin"))
                        return BulletinTemplate;                  
                }
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}
